package com.g5.edu.controller;

import com.g5.edu.service.IDfUsersInfoService;
import com.g5.edu.vo.RegisterVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.rowset.serial.SerialException;

@RestController  //返回字符串，则就认为是字符串
//@Controller   //返回字符串，则认为是页面的名字，要跳转页面
@Slf4j
public class SystemController {
    @Autowired
    private IDfUsersInfoService iDfUsersInfoService;

    @PostMapping("/register")
    public String register(
            @Validated RegisterVo registerVo, BindingResult result) {
        log.info("接收到用户信息:{}",registerVo);
        //
//        if (result.hasErrors()){
//            String msg = result.getFieldError().getDefaultMessage();
//            return msg;
//        }
        iDfUsersInfoService.register(registerVo);
        //注册成功跳转的页面名字
        return "ok";
    }




}
